<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <input id="first-number" type="number" placeholder="请输入第一个数字">
  <input id="second-number" type="number" placeholder="请输入第二个数字">
  <button id="sum-action" onclick="getSum()">求和</button>
  <p id="sum">
    两个输入框之和为 <span id="result"></span>
  </p>

  <script>
    var input1 = document.getElementById("first-number");
    var input2 = document.getElementById("second-number");
    var resultContent = document.getElementById("result")




    function getSum() {
      var input1Value = input1.value - 0
      var input2Value = input2.value - 0
      var sum = input1Value + input2Value
      resultContent.innerHTML = sum
    }

  </script>
</body>

</html>